<%-- 
    Document   : index
    Created on : Jan 21, 2013, 7:45:48 PM
    Author     : Vrety
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Diet Planning</title>
        <link href="css/register.css" rel="stylesheet" type="text/css">
        <script type="text/javascript">

            function declare(){
                document.getElementById("registerForm").style.visibility ='hidden';
            }

            //Check not empty
            function checkvalidLogin (username, password) {

                if (username === '' || password === '') {
                    alert ('Vui lòng nhập Email và Mật khẩu');
                    return false;
                }
                document.forms["LoginForm"].submit();
            }
           
           
            function showRegister () {
                document.getElementById("registerLink").style.visibility ='hidden'; // show
                document.getElementById("registerForm").style.visibility = 'visible'; // show
            }
           
            function confirm()
            {
                var x=document.forms["myForm"]["email"].value;
                var atpos=x.indexOf("@");
                var dotpos=x.lastIndexOf(".");
                if ($("#re_InputPassWord").val()!=$("#InputNewPassword").val()){
                    document.getElementById("msgError").innerHTML="Mật khẩu không trùng khớp!";
                    return false;
                } else if ($("#InputEmail").val()!=$("#re_InputEmail").val()){
                    document.getElementById("msgError").innerHTML="Email không trùng khớp!";
                    return false;
                } else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
                {
                    alert("Vui lòng điền đúng địa chỉ Email");
                    return false;
                }
            }
            function confirmPassword(){
                if ($("#re_InputPassWord").val()!=$("#InputNewPassword").val()||
                    $("#InputEmail").val()!=$("#re_InputEmail").val()){
                    document.getElementById("msgError").innerHTML="Mật khẩu hoặc Email không trùng khớp!";
                    return false;
                }
            }

        </script>
    </head>

    <body >
        <jsp:include page="homeHeader.jsp"/>

        <form  action="ControllerServlet" name="Register" id="registerForm" method="post" onsubmit="return confirm();" >
            <div class="inside-botton-content-left">
                <fieldset > <legend><h2>Đăng Ký Tài Khoản</h2></legend>

                    <label>Email : </label>
                    <input type="email" name="txtEmail" id="InputEmail" size ="40" required /><span class="required" >* </span><br/>
                    <label>Nhập lại Email : </label>
                    <input name="re_reg_email" id="re_InputEmail" type="reemail" size="40" required/>
                    <span class="required" >* </span><br/>
                    <br/>
                    <label>Mật khẩu : </label>
                    <input type="password" size ="40" name="txtPassword" id="InputPassWord" required maxlength="20"/><span class="required" >* </span> <br />
                    <label>Nhập lại mật khẩu : </label>
                    <input name="re_InputPassWord" id="re_InputPassWord" type="password" size="40" required  maxlength="20"/>
                    <span class="required">* </span><br/>

                    <br/>
                    <div id="msgError" style="color: red;"></div>
                    <input type="submit" value="Register" name="btnAction" id="btnRegister"
                           onclick="confirmPassword()"/>
                </fieldset>
            </div>
        </form>

<!--        <form action="ControllerServlet" method="POST">
            <input type="submit" value="Test" name="btnAction" />
        </form>-->
    </body>
</html>
